//
//  HMStatusBottomView.swift
//  HMWeibo12
//
//  Created by iOS on 16/9/23.
//  Copyright © 2016年 iOS. All rights reserved.
//

import UIKit

class HMStatusBottomView: UIView {

    // 转发按钮
    @IBOutlet var retweetButton: UIButton!
    
    // 评论按钮
    @IBOutlet var commentButton: UIButton!
    
    // 赞按钮
    @IBOutlet var likeButton: UIButton!
    
    var statusVM: HMStatusVM? {
        didSet {
            // 设置3个按钮的数量
//            let reposts_count = statusVM?.status.reposts_count ?? 0
//            let comments_count = statusVM?.status.comments_count ?? 0
//            let attitudes_count = statusVM?.status.attitudes_count ?? 0
//            
//            let repostString = countString(count: reposts_count, defaultString: "转发")
//            let commentString = countString(count: comments_count, defaultString: "评论")
//            let attitudeString = countString(count: attitudes_count, defaultString: "赞")
            
            retweetButton.setTitle(statusVM?.repostString, for: .normal)
            commentButton.setTitle(statusVM?.commentString, for: .normal)
            likeButton.setTitle(statusVM?.attitudeString, for: .normal)
        }
    }
    
//    private func countString(count: Int, defaultString: String) -> String {
//        if count == 0 {
//            return defaultString
//        }
//        
//        if count >= 10000 {
//            // 1.01 万
//            // 10111 -> 1.0111 万 -> 1.01
//            let newCount = Double(count) / 10000
//            // ... 表示可变参数
//            return String(format: "%.02f", newCount) + "万"
//        } else {
//            // 1 - 9999
//            return "\(count)"
//        }
//    }

}
